#pragma once
#include <Windows.h>

class Heap
{
public:
	Heap(bool syn) {
		m_Syn = (syn ? 0 : HEAP_NO_SERIALIZE);
		m_HeapHandle = HeapCreate(m_Syn,0,0);
	}

	~Heap() {
		if(m_HeapHandle)
			HeapDestroy(m_HeapHandle);
	}
	
	void* alloc(size_t size) {
		return HeapAlloc(m_HeapHandle,m_Syn,size);
	}

	void* alloc(size_t size,bool syn) {  
		return HeapAlloc(m_HeapHandle,syn ? 0 : HEAP_NO_SERIALIZE,size);
	}

	void free(void*p ) {
		HeapFree(m_HeapHandle,m_Syn,p);
	}

	void free(void* p,bool syn) {
		HeapFree(m_HeapHandle,syn ? 0 : HEAP_NO_SERIALIZE,p);
	}

private:
	HANDLE m_HeapHandle;
	DWORD m_Syn;
};